Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
Angular 2: "router.navigate" Encoding error in the URL

When I submit a form, I want to navigate to another site and set the search values in the URL as parameters.

I've got following code:

searchOffers() {
    this.router.navigate([
      '/search?query= +
        this.search.value.FG
    ]);
  }

This Code work's, but the URL look like this after the routing.

localhost:4200/search%3Fquery%3D1 

(The query parameter value is 1).

With this URL I cant fetch the parameters.

How can I format the URL to this: localhost:4200/search?query=1 ?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I've had the case where I get a string with the whole url including the query params.

In this case you can do this

    searchOffers() {
    this.router.navigateByUrl('/search?query= +
        this.search.value.FG);
    }
about 4 years ago · Santiago Trujillo Relatório

0

Make use of the options parameter:

searchOffers() {
    this.router.navigate(['/search'], { queryParams: { query: this.search.value.FG } });
  }
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda